//
//  HeaderTailRowView.swift
//  IndustryNet
//
//  Created by topnet on 2022/1/20.
//

import UIKit

class HeaderTailRowView: UIView {
    
    var insets = UIEdgeInsets.zero
    var tailMinWidth = 80.adapter
    init() {
        super.init(frame: .zero)
        da.addSubviews(sub: [headerLbl, tailLbl])
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        headerLbl.centerY(bounds.height/2).left(insets.left)
        headerLbl.fitSize(maxSize: CGSize(width: bounds.width - insets.left - insets.right - tailMinWidth, height: 20.adapter))
        tailLbl.top_bottom_offsetLeft(headerLbl, x: 8.adapter).right(bounds.width-insets.right)
        
    }
    
    func config(title: String?,
                content: String?,
                hasArrow: Bool = true) {
        headerLbl.text = title
        tailLbl.text = (content ?? "") + (hasArrow ? IconFont.arrow_right : "")
       
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var headerLbl: UILabel = {
       let v = UILabel()
        v.textColor = .title
        v.font = .font(15)
        return v
    }()
    lazy var tailLbl: UILabel = {
        let v = UILabel()
         v.textColor = .content
         v.font = .iconfont(13)
        v.textAlignment = .right
         return v
     }()
}
